<script>
    img=true;
     var img_sh = "<%=image_path("lodging.shadow.png")%>";
     var img_p =  "<%=image_path("lodging.png")%>";
</script>
<div id="left"></div>
<div id="right">
<% if (session[:role] == "admin") %>
<h1>Listing residents</h1>

<table class="three" cellspacing="0">
  <tr>
    <th>Name</th>
    <th>Province</th>
    <th>Detail</th>
    <th>Lat</th>
    <th>Long</th>
    <th>Img</th>
    <th>Rate</th>
  </tr>

<% @residents.each do |resident| %>
  <tr>
    <td><%=h resident.name %></td>
    <td><%=h resident.province %></td>
    <td><%=h resident.detail %></td>
    <td><%=h resident.lat %></td>
    <td><%=h resident.long %></td>
    <td><%=h resident.img %></td>
    <td><%= link_to 'Show', resident %></td>
    <td><%= link_to 'Edit', edit_resident_path(resident) %></td>
    <td><%= link_to 'Destroy', resident, :confirm => 'Are you sure?', :method => :delete %></td>
  </tr>
<% end %>
</table>
<% elsif session[:user] %>
<h2>ที่พัก</h2>
<ul>
 <% for resident in @residents %>
  <li>
    <%= link_to resident.province,
      :action => "show",
      :id => resident %>
  </li>
<% end %></ul>
<br />

<%= link_to 'เพิ่มจังหวัดที่พัก', new_resident_path %>
<% else %>
<p>สมัครสมาชิกเพื่อใช้งาน ... </p>
<% end %>
</div>
<br />